<?php

declare(strict_types=1);

namespace app\listener;

use think\swoole\Websocket;

class WsEvent
{
    /**
     * 事件监听处理
     *
     * @return mixed
     */
    public function handle($event, Websocket $ws)
    {
        echo '事件监听';

        // dump($event);
        // dump($ws->getSender());

        // echo $event['msg'];

        $obj = json_decode($event->data, true);

        dump($obj);
        // dump($obj['user_id']);
        // dump($obj['msg']);
        // dump($obj['to_user_id']);

        // $ws->to($ws->getSender())->emit('chat', $obj->msg);
    }
}
